/**
 * Created by Administrator on 2017/1/22.
 */
var supplier_token;
$.ajax({
    type:'GET',
    url:'http://192.168.1.72:8098/api/cft/admin/get/token',
    contentType:'application/json; charset=gbk',
    data:'',
    dataType:'json',
    success:function (res) {
        supplier_token = res.data;
        console.log(supplier_token);
    },
    error:function (res) {
        layer.msg('登陆失败');

    }
});
alert('1');
$('.save').click(function () {
    var shoplist_name = $('#shoplist_name').val();//店铺名称
    var shoplist_bossphone = $('#shoplist_bossphone').val();//老板手机号
    var shoplist_shoperphone = $('#shoplist_shoperphone').val();//店主手机号
    var shoplist_telephone = $('#shoplist_telephone').val();//客服电话
    var shoplist_text = $('#shoplist_text').val();//店铺介绍
    var shoplist_address = $('#shoplist_address').val();//店铺地址
    var shoplist_latlng = $('#shoplist_latlng').val();//店铺坐标
    var shoplist_servicename = $('#shoplist_servicename').val();//服务名称
    var shoplist_servicetext = $('#shoplist_servicetext').val();//服务介绍
    var shoplist_servicemoney = $('#shoplist_servicemoney').val();//服务金额

    var arr = $('#shoplist_latlng').val().split(',');//分割经纬度
    var lat = arr[0];//纬度
    var lng = arr[1];//经度

    if(shoplist_name == '' || shoplist_name == null || shoplist_name == undefined){
        layer.msg('店铺名称不能为空');
    }else
    if(shoplist_bossphone == '' || shoplist_bossphone == null || shoplist_bossphone == undefined){
        layer.msg('老板手机号不能为空');
    }else
    if(shoplist_shoperphone == '' || shoplist_shoperphone == null || shoplist_shoperphone == undefined){
        layer.msg('店主手机号不能为空');
    }else
    if(shoplist_telephone == '' || shoplist_telephone == null || shoplist_telephone == undefined){
        layer.msg('客服电话不能为空');
    }else
    if(shoplist_text == '' || shoplist_text == null || shoplist_text == undefined){
        layer.msg('店铺介绍不能为空');
    }else
    if(shoplist_address == '' || shoplist_address == null || shoplist_address == undefined){
        layer.msg('店铺地址不能为空');
    }else
    if(shoplist_latlng == '' || shoplist_latlng == null || shoplist_latlng == undefined){
        layer.msg('店铺坐标不能为空');
    }else
    if(shoplist_servicename == '' || shoplist_servicename == null || shoplist_servicename == undefined){
        layer.msg('服务名称不能为空');
    }else
    if(shoplist_servicetext == '' || shoplist_servicetext == null || shoplist_servicetext == undefined){
        layer.msg('服务介绍不能为空');
    }else
    if(shoplist_servicemoney == '' || shoplist_servicemoney == null || shoplist_servicemoney == undefined){
        layer.msg('服务金额不能为空');
    }else{
        $.ajax({
            type:'POST',
            url:'http://192.168.1.72:8098/api/cft/admin/create/shop',
            contentType:'application/json',
            data:JSON.stringify({'supplyId':'1','token':supplier_token,'name':shoplist_name,'ownerMobile':shoplist_bossphone,'managerMobile':shoplist_shoperphone,'telephone':shoplist_telephone,'description':shoplist_address,'lat':lat,'lgt':lng}),
            dataType:'json',
            success:function (res) {
                layer.msg(res.message);
                $('.indexlist').show();
                $('.newtankuang').hide();
            },
            error:function (res) {
                layer.msg('添加失败');
            }
        })
    }
});